package orm

import (
	"fmt"

	"gorm.io/driver/mysql"
	"gorm.io/gorm"
	"gorm.io/gorm/schema"
)

var DB *gorm.DB

const passwrod = "liaoxiang"
const dbName = "gorm_test"

func init() {
	dsn := fmt.Sprint("root:", passwrod, "@tcp(127.0.0.1:3306)/", dbName, "?charset=utf8mb4&parseTime=True&loc=Local")
	database, err := gorm.Open(mysql.New(mysql.Config{
		DSN: dsn,
	}), &gorm.Config{
		NamingStrategy: schema.NamingStrategy{SingularTable: true},
	})
	DB = database
	if err != nil {
		fmt.Println("faider err", err)
		return
	}
}
